from thrift.transport import TSocket
from thrift.transport.TTransport import TBufferedTransport
from thrift.protocol import TBinaryProtocol

from hbase import Hbase
from hbase.ttypes import *

def create_client(transport):
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    transport.open()
    return Hbase.Client(protocol)

def close_trans(transport):
    transport.close()

def get_all_name(client):
    for table_name in client.getTableNames():
        print(table_name)


if __name__ == '__main__':
    socket = TSocket.TSocket('master', 9090)
    transport = TBufferedTransport(socket)
    client = create_client(transport)
    get_all_name(client)
    close_trans(transport)